
let BaseComponent = require('BaseComponent');


cc.Class({
    extends: BaseComponent,

    properties: {
        num: 2,
        cardFace: cc.Sprite
    },

    onLoad() {
        this.width = this.cardFace.node.width;
        this.height = this.cardFace.node.height;
    },

    setNum(num, callback) {
        this.num = num;

        this.cardFace.loadTexture('Texture/'+ this.num, callback);
    },

    getBox() {
        return cc.rect(
            this.x - this.width / 2 * this.scale,
            this.y - this.height / 2 * this.scale,
            this.width * this.scale,
            this.height * this.scale
        );
    },
    containsPoint(p) {
        p = this.node.parent.convertToNodeSpaceAR(p);
        return cc.rectContainsPoint(this.getBox(), p);
    }
});